// Copyright (c) 2020 Presto Labs Pte. Ltd.
// Author: leon

#pragma once

#include <map>
#include <memory>
#include <regex>
#include <string>
#include <vector>

// internal
#include "coin2/exchange/base/feed/processor.h"
#include "coin2/exchange/base/market/enums.h"
#include "coin2/exchange/di/constant.h"

namespace coin2::exchange::ftx_common::feed_v1 {
namespace impl {
class FtxCommonFeedProcessor : public base::feed::FeedParsingProcessor {
 public:
  explicit FtxCommonFeedProcessor(
      const std::string& system_name,
      const coin2::exchange::di::ConstantInjection& ci,
      const feed::RawParserConfig& config,
      const MarketExchangeApi& mea)
      : FeedParsingProcessor(
            system_name,
            mea,
            ci,
            config,
            "cc/coin2/exchange/ftx_common/feed_v1/schema.json") {}
  void OnTopicRecord(const base::executor::TopicRecordPacket& packet) override;
};
struct FtxCommonChannel {
  std::string channel;

  static FtxCommonChannel Parse(
      const std::string& type,
      const std::string& channel) {
    /*
    {"type": "subscribed", "channel": "ticker", "market": "BTC-0626"}
    {"channel": "ticker", "market": "BTC-PERP", "type": "update", ...
    {"channel": "orderbook", "market": "BTC-0925", "type": "update", ...
    {"channel": "trades", "market": "BTC-PERP", "type": "update", ...
    */
    if (type == "subscribed" || type == "unsubscribed") {
      return FtxCommonChannel{"ignored"};
    } else {
      return FtxCommonChannel{channel};
    }
  }
};
};  // namespace impl
using impl::FtxCommonChannel;
using impl::FtxCommonFeedProcessor;
}  // namespace coin2::exchange::ftx_common::feed_v1
